package process

import (
	"matching/engine"
	"matching/errcode"
	log "github.com/cihub/seelog"
	"matching/middleware/cache"
)

//关闭撮合引擎
func CloseEngine(symbol string) errcode.ErrorCode  {
	if engine.ChanMap[symbol]==nil {
		//已经关闭过
		return errcode.StopOver
	}
	log.Infof(" %s engine is closed，next time will start no more,if you want it work,you should open by yourself", symbol)
	close(engine.ChanMap[symbol])
	return errcode.Success
}


func CloseEngineAll() errcode.ErrorCode  {
	symbols:=cache.GetSymbols()
	for _,value:=range symbols{
		log.Infof(" %s engine is closed，next time will start no more,if you want it work,you should open by yourself", value)
		close(engine.ChanMap[value])
	}
	return errcode.Success
}